var app = getApp();
Page(Object.assign({},{
    data:{
        inited : false,
        form : {},
        showqun : false,
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
        paytypename : '',
        paytype : 0,

    },
    onShow(){
        if(this.data.inited){
            this.onLoad();
        }
    },
    onLoad:function(options){
        var self = this;
        app.com.auth(function(user){
            app.com.http('admin','POST',{op:'drawinit'},0,false,'','',function(res){
                if (!res.data.errno) {
                    self.setData({
                        params : res.data.data.params,
                        inited : true,
                    });
                    // 关闭下拉刷新
                    wx.stopPullDownRefresh();
                }
            });
        },self);

        wx.setNavigationBarTitle({
          title:  '提现',
        });
    },
    onShareAppMessage : function(){
        var self = this;
        return {
            title: self.data.sharedata.title,
            path: '',
        }
    },
    addthis : function(e){
        this.setData({
            money : e.currentTarget.dataset.m
        })
    },
    showtype(){
        this.setData({
            isshowtype : !this.data.isshowtype,
        })
    },
    confirm(e){
        var self = this;
        
        if( self.data.money*1 <= 0 || !self.data.money ) {
            app.com.toast('请填写提现金额','none');
            return false;
        }
        var postdata = {
            op:'draw',
            money : self.data.money,
            paytype : self.data.params.type,
            v : 1,
        };

        if( self.data.payed ) return false;
        self.data.payed = true;

        app.com.http('admin','POST',postdata,0,true,'','',function(res){
            if (!res.data.errno) {
                app.com.toast(res.data.message,'success',function(){
                    wx.navigateBack();
                });
            }else{
                app.com.toast(res.data.message);
                if( res.data.errno == 2 ){
                    wx.navigateTo({
                        url : res.data.data.url
                    });
                }              
            }
            self.data.payed = false;
        });
    },
    confirmpay(e){
        this.setData({
            'params.type' : e.detail.value.id,
            'params.paytypename' : e.detail.value.name,
            isshowtype : false,
        })
    },
    money : function(e){
        this.setData({
            money : e.detail.value
        })
    },
    showqun(){
        this.setData({
            showqun : !this.data.showqun,
        })
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e,this.data.tid );
    },
    redirectto : function( e ){
        app.com.redirectto( e,this.data.tid );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    }
}))